/*===========================================================================================================================
	Wolf Prop Protection
		By Goluch
			E2 Functions
			
	Section: Varible Funcs
===========================================================================================================================*/
E2Lib.RegisterExtension("wpp", true)


e2function number wppTouch() return WPP_PHYSGUN || 0 end
e2function number wppPickUp() return WPP_GRAB || 0 end
e2function number wppTool() return WPP_TOOL || 0 end
e2function number wppRemove() return WPP_REMOVE || 0 end
e2function number wppDuplicate() return WPP_DUPLICATE || 0 end
e2function number wppUse() return WPP_USE || 0 end
e2function number wppNoClip() return WPP_NOCLIP || 0 end
e2function number wppDamage() return WPP_DANAGE || 0 end
e2function number wppCPPI() return WPP_CPPI || 0 end

/*===========================================================================================================================
	Name: wppPlayerCan
	Purpose:
	Author: Goluch
===========================================================================================================================*/
e2function number entity:wppPlayerCan(entity Entity,Access)
	if ( !WPP:IsValidAction(Access) ) then return 0 end
	if ( !WPP:IsValid(Entity) ) then return 0 end
	if ( !this:IsValid() ) or ( !this:IsPlayer() ) then return 0 end
	
	if ( WPP:ValidateAction(Access,Entity,this) ) then return 1 end
	return 0
end

/*===========================================================================================================================
	Name: wppPlayerTrusts
	Purpose:
	Author: Goluch
===========================================================================================================================*/
e2function number entity:wppPlayerTrusts(entity Player,Access)
	if ( !WPP:IsValidAction(Access) ) then return 0 end
	if ( !this:IsValid() ) or ( !this:IsPlayer() ) then return 0 end
	if ( !Player:IsValid() ) or ( !Player:IsPlayer() ) then return 0 end
	
	if ( WPP:GetTrust(this,Player,Access) ) then return 1 end
	return 0
end

/*===========================================================================================================================
	Name: wppGetTrust
	Purpose:
	Author: Goluch
===========================================================================================================================*/
e2function number entity:wppGetTrust(Access)
	if ( !WPP:IsValidAction(Access) ) then return 0 end
	if ( !this:IsValid() ) or ( !this:IsPlayer() ) then return 0 end
	
	local Player = WPP:GetOwner(self)
	if ( !Player ) or ( !Player:IsValid() ) or ( !Player:IsPlayer() ) then return 0 end
	
	if ( WPP:GetTrust(Player,this,Access) ) then return 1 end
	return 0
end

/*===========================================================================================================================
	Name: wppSetTrust
	Purpose:
	Author: Goluch
===========================================================================================================================*/
e2function void entity:wppSetTrust(Access,Allow)
	if ( !WPP:IsValidAction(Access) ) then return end
	if ( !this:IsValid() ) or ( !this:IsPlayer() ) then return end
	
	local Player = WPP:GetOwner(self)
	if ( !Player ) or ( !Player:IsValid() ) or ( !Player:IsPlayer() ) then return end
	
	local Bool = false
	if ( Allow >= 1 ) then Bool = true end
	
	WPP:SetTrust(Player,this,Access,Bool)
end

/*===========================================================================================================================
	Name: wppGetPropShare
	Purpose:
	Author: Goluch
===========================================================================================================================*/
__e2setcost(120)
e2function number entity:wppGetPropShare(Access)
	if ( !WPP:IsValidAction(Access) ) then return 0 end
	if ( !WPP:IsValid(this) ) then return 0 end
	
	if ( WPP:GetShare(this,Access) ) then return 1 end
	return 0
end

/*===========================================================================================================================
	Name: wppSetPropShare
	Purpose:
	Author: Goluch
===========================================================================================================================*/
__e2setcost(120)
e2function void entity:wppSetPropShare(Access,Allow)
	if ( !WPP:IsValidAction(Access) ) then return end
	if ( !WPP:IsValid(this) ) then return end
	
	local Player = WPP:GetOwner(self)
	if ( !Player ) or ( !Player:IsValid() ) or ( !Player:IsPlayer() ) then return end
	if ( !WPP:IsOwner(this,Player) ) then return end
	
	local Bool = false
	if ( Allow >= 1 ) then Bool = true end
	
	WPP:SetShare(this,Access,Bool)
end

/*===========================================================================================================================
	E2 Function Help:
	
	Number = wppTouch() -> The number returned represents the Touch Action.
	Number = wppPickUp() -> The number returned represents the PickUp Action.
	Number = wppTool() -> The number returned represents the Tool Action.
	Number = wppRemove() -> The number returned represents the Remove Action.
	Number = wppDuplicate() -> The number returned represents the Duplicate Action.
	Number = wppUse() -> The number returned represents the Use Action.
	Number = wppNoClip() -> The number returned represents the NoClip Action.
	Number = wppCPPI() -> The number returned represents the CPPI Action.

	Number = Player:wppPlayerCan(Entity,Access) -> Returns (0/1) if Player can do the Action on Entity.
	Number = Player:wppPlayerTrusts(Player,Access) -> Returns (0/1) if Player1 trusts Player2 to do Action.
	Number = Player:wppGetTrust(Access) -> Returns (0/1) if the E2 owner trusts Player to do Action.
	Number = Entity:wppGetPropShare(Access) -> Retruns (0/1) if Entity has PropShare Acces for Action.

	Player:wppSetTrust(Access,Allow) -> Sets the E2s owners trust for player to do action when allow is (0/1).
	Entity:wppSetPropShare(Access,Allow) -> Sets the PropShare fro Action on Entity, When the E2 owner owns Entity.

===========================================================================================================================*/